#region Using
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
#endregion Using

namespace PhotoGallery.Core.Services.DALService
{
    internal sealed class EventInfoService
    {
        #region Constructor

        static EventInfoService()
        {
            LoadProvider();
        }

        #endregion Constructor

        #region Provider model

        private static volatile Providers.DALProvider.IEventInfoProvider provider;
        private static object syncLock = new object();

        private static void LoadProvider()
        {
            if (provider == null)
            {
                lock (syncLock)
                {
                    if (provider == null)
                    {
                        string path = PhotoGallery.Configuration.ConfigurationManager.Providers.DALProviders.Default.Path;
                        string className = PhotoGallery.Configuration.ConfigurationManager.Providers.DALProviders.Default.Namespace + ".EventInfoProvider";
                        provider = System.Reflection.Assembly.Load(path).CreateInstance(className) as Providers.DALProvider.IEventInfoProvider;
                    }
                }
            }
        }

        #endregion Provider model

        public static Business.EventInfo Select(int id)
        {
            return provider.Select(id);
        }

        public static void Update(Business.EventInfo eventInfo)
        {
            provider.Update(eventInfo);
        }

        public static void Delete(Business.EventInfo eventInfo)
        {
            provider.Delete(eventInfo);
        }

        public static void Insert(Business.EventInfo eventInfo)
        {
            provider.Insert(eventInfo);
        }



        public static ICollection<Business.EventInfo> GetAllOrder()
        {
            return provider.GetAllOrder();
        }
    }
}
